package com.itheima.conllection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class ConllectionDemo01 {
    public static void main(String[] args) {
//        Collection<String> collection=new ArrayList<>();
//        collection.add("aaa");
//        collection.add("bbb");
//        collection.add("ccc");
//        collection.add("dddd");
//        System.out.println(collection);
//        System.out.println(collection.remove("aaa"));
//        System.out.println(collection.removeIf((String s) -> {
//            return s.length() == 3;
//        }));
//        System.out.println(collection);
        Collection<Student> collection=new ArrayList<>();
        Student stu1=new Student("zs",18);
        Student stu2=new Student("ls",20);
        collection.add(stu1);
        collection.add(stu2);
//        System.out.println(collection.contains(stu2));
//        System.out.println(collection.remove(stu1));
//        System.out.println(collection.removeIf((Student s) -> {
//            return s.getName().equals("zs");
//        }));
//        System.out.println(collection);
//        System.out.println(collection.size());
//        collection.clear();
//        System.out.println(collection.isEmpty());
//        System.out.println(collection);
        Iterator<Student> it = collection.iterator();
        while (it.hasNext()){
            Student next = it.next();
//            if (next.getName().equals("zs")){
//                it.remove();
//            }
            System.out.println(next);
        }
        System.out.println("--------------");
        for (Student student:collection){
            System.out.println(student);
        }
        System.out.println(collection);
    }
}
